<!DOCTYPE html>
<head>
    <meta charset="utf-8">
    <script src="/jquery/jquery-3.3.1.min.js"></script>
</head>
<body>
<script src="/jquery/common.js"></script>
<div>
    <img  src="" class="img">
</div>
<form method="post" action="/photo/addIndexPhoto" enctype="multipart/form-data">
    <input name="description" placeholder="请输入图片描述">
    <input name="file" type="file" class="imgInput"/>
    <input type="submit" value="提交" />
</form>
</body>

<script>
    $(".imgInput").change(function(){
        $(".img").attr("src",URL.createObjectURL($(this)[0].files[0]));
    });
</script>
</html>